'''
''' This handler validates the page whenever the text in the ${Validate Field Control} TextBox changes.
''' The TextChanged handler is called when the value is changed.
'''
Private Sub ${Validate Field Control}_TextChanged(ByVal sender As Object, _
ByVal e As System.EventArgs)
Try
Validate()
Catch ex As Exception
' Exception thrown by the Validate() sub is caught here.
' Report the error message to the user.
Utils.MiscUtils.RegisterJScriptAlert(Me, "UNIQUE_SCRIPTKEY","${Validate Field Control} cannot be empty ")
End Try
End Sub
'''
''' Override the Validate() method. Add your validation logic here.
''' If the value of ${Validate Field Control} is not valid
''' then throw an exception. The exception is caught in the ${Validate Field Control}_TextChanged
''' event handler and it calls RegisterJScriptAlert to report the error message to the user.
''' Throwing an exception in Validate() sub ensures that the record will not be saved. If you do not throw an exception
''' record will be saved. You can also validate other fields in the Validate() sub.
''' In this customization ${Validate Field Control}_TextChanged will report an error message to the user
''' if an exception is thrown by the Validate method. After the ${Validate Field Control}_TextChanged event
''' when the user clicks on the save button, the exception thrown by the Validate() sub will get caught
''' by the SaveButton_Click handler, which will call the RegisterJScriptAlert to report the error message to the user.
'''
Public Overrides Sub Validate()
MyBase.Validate()
' Add validation logic here
If (Me.${Validate Field Control}.Text = "") Then
Throw New Exception
End If
End Sub
|